Expecting Exceptions Anywhere ^^^^^ **Definition:** * Tests that do not track the step that raised the expected exception and pass **Code Example:** .. code-block:: java @Test(expected=IndexOutOfBoundsException.class) public void testMyList() { MyList list = new MyList(); list.add(1); list.add(2); list.add(3); list.add(3); list.add(4); assertTrue(4 == list.get(4)); assertTrue(2 == list.get(1)); assertTrue(3 == list.get(2)); list.get(6); } @Test(expected=IndexOutOfBoundsException.class) public void testNegative() { MyList list = new MyList(); list.add(1); list.add(2); list.add(3); list.add(3); list.add(4); list.get(-1); } } **References:** .. admonition:: Quality attributes * :octicon:`file-code;1em` - Code Example * :octicon:`comment-discussion;1em` - Cause and Effect * :octicon:`graph;1em` - Frequency * :octicon:`sync;1em` - Refactoring * `Bad tests, good tests `_ :octicon:`file-code;1em` :octicon:`comment-discussion;1em` :octicon:`sync;1em`